//
//  ViewController.m
//  Gif
//
//  Created by Yan Hu on 2018/7/11.
//  Copyright © 2018年 yan. All rights reserved.
//

#import "ViewController.h"
#import "ANGifEncoder.h"
#import "ANGifBitmap.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)convert {
    NSString * fileName = [NSString stringWithFormat:@"%@/Documents/foo.gif", NSHomeDirectory()];
    ANGifBitmap * bmp = [[ANGifBitmap alloc] initWithImage:[UIImage imageNamed:@"ball.png"]];
    ANGifBitmap * bmp2 = [[ANGifBitmap alloc] initWithImage:[UIImage imageNamed:@"ball2.png"]];
    ANGifBitmap * bmp3 = [[ANGifBitmap alloc] initWithImage:[UIImage imageNamed:@"ball3.png"]];
    ANGifEncoder * enc = [[ANGifEncoder alloc] initWithFile:fileName animated:YES];
    [enc beginFile:bmp.size
         delayTime:0.6];
    [enc addImage:bmp];
    [enc addImage:bmp2];
    [enc addImage:bmp3];
    [enc endFile];
    NSLog(@"%@", fileName);
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self performSelector:@selector(convert) withObject:nil afterDelay:0.1];
}

@end
